package com.example.springbootshiro.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.springbootshiro.entity.ShiroUser;
import com.example.springbootshiro.mapper.ShiroUserMapper;
import com.example.springbootshiro.service.ShiroUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author vicente
 * @since 2022-01-11
 */
@Service
public class ShiroUserServiceImpl extends ServiceImpl<ShiroUserMapper, ShiroUser> implements ShiroUserService {

    @Override
    public ShiroUser getUserByName(String userName) {
        // 条件查询，下面相当于xml中的 select * from mp_user where login_name = 'Tom' limit 1
        ShiroUser user = this.getOne(new QueryWrapper<ShiroUser>().eq("login_name", userName).last("limit 1"));
        System.out.println("mpUser=" + JSON.toJSONString(user));
        return user;
    }
}
